﻿using NHibernate.Mapping.Attributes;
using NHibernate.Tool.hbm2ddl;
using RHD.Data.Model;
using Spring.Data.NHibernate;

namespace RHD.Data.NHibernate {
	public class AttributeSessionFactoryObject : LocalSessionFactoryObject {

		protected override void PostProcessConfiguration(global::NHibernate.Cfg.Configuration config) {
			config.AddInputStream(HbmSerializer.Default.Serialize(typeof(BaseModel).Assembly));
			base.PostProcessConfiguration(config);

			schemaExport(config);
		}

		private void schemaExport(global::NHibernate.Cfg.Configuration config) {
			SchemaExport exporter = new SchemaExport(config);
			exporter.Create(true, true);
		}
	}
}